/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package aviso.property.entity;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 *
 * @author avgusti
 */
@Entity
@Table(name = "PROPERTY_TABLE")
public class Property implements Serializable {

    public enum PropertyType {
        // 0     1   2(double) 3   4(CLOB) 5(Timestamp)

        String, Long, Number, Bool, Text, Date
    }

    public enum PropertyRangeType {

        // 0            1               2       3        4       5       6       7       8
        None, SingleValue, MultipleValues, Between, Auto, Auto5, Auto10, Auto25, Auto50;

        public int getCount() {
            switch (this) {
                case Auto:
                    return 10;
                case Auto5:
                    return 5;
                case Auto10:
                    return 10;
                case Auto25:
                    return 25;
                case Auto50:
                    return 50;
                default:
                    return 0;

            }
        }
    }
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    @Column(name = "range_col")
    private PropertyRangeType range = PropertyRangeType.MultipleValues;
    private String name;
    private PropertyType type;
    @ManyToOne
    private PropertyGroup group;
    @ManyToOne
    private ItemCategory category;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public PropertyRangeType getRange() {
        return range;
    }

    public void setRange(PropertyRangeType range) {
        this.range = range;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public ItemCategory getCategory() {
        return category;
    }

    public void setCategory(ItemCategory category) {
        this.category = category;
    }

    public PropertyGroup getGroup() {
        return group;
    }

    public void setGroup(PropertyGroup group) {
        this.group = group;
    }

    public PropertyType getType() {
        return type;
    }

    public void setType(PropertyType type) {
        this.type = type;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Property other = (Property) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 29 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return "Property{" + "id=" + id + ", name=" + name + ", type=" + type + ", group=" + group + ", category=" + category + '}';
    }
}
